package com.freshcity.component
{
	import com.freshcity.component.container.Component;
	
	import flash.display.Sprite;
	import flash.text.StyleSheet;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;

	public class FLabel extends Component
	{
		private var _tf:TextField;
		private var _text:String;
		private var _textFormat:TextFormat;

		public function FLabel(text:String, xpos:Number=0, ypos:Number=0, fontColor:uint=0xffffff, fontSize:String="12", fontName:String="宋体")
		{
			_text=text;
			_textFormat=new TextFormat(fontName, fontSize, fontColor);
			super(null, xpos, ypos);
		}

		override protected function addChildren():void
		{
			super.addChildren();
			_tf=new TextField();
			_tf.autoSize=TextFieldAutoSize.LEFT;
			_tf.selectable=true;
			_tf.mouseEnabled=true;
			_tf.wordWrap=true;
			_tf.multiline = true;
			addChild(_tf);
		}

		override public function draw():void
		{
			super.draw();
			_tf.defaultTextFormat=_textFormat;
			_tf.text=_text;
		}

		public function set textFormat(value:TextFormat):void
		{
			_textFormat=value;
		}

		public function setText(value:String):void
		{
			_text=value;
			this.invalidate();
		}
	}
}
